package com.tfswx.jcyw.sqlmodel.web;

import cn.hutool.core.io.FileUtil;
import com.alibaba.fastjson.JSON;
import com.tfswx.jcyw.sqlmodel.api.SqlModelFactory;
import com.tfswx.jcyw.sqlmodel.api.bean.ExecuteInputDTO;
import com.tfswx.jcyw.sqlmodel.api.bean.Node;
import com.tfswx.jcyw.sqlmodel.api.executor.SqlModelExecutor;
import com.tfswx.jcyw.sqlmodel.gic.DefaultSqlModelFactory;

import java.io.File;
import java.nio.charset.StandardCharsets;
import java.util.*;

/**
 * @author 张述江
 * @date 2023-09-25
 */
public class Test {
    public static void main(String[] args) {

        SqlModelFactory sqlModelFactory = SqlModelFactory.getSqlModelFactory(DefaultSqlModelFactory.class);
        SqlModelExecutor sqlModelExecutor = sqlModelFactory.createSqlModelExecutor();

        ExecuteInputDTO executeInputDTO = new ExecuteInputDTO();

        String s = FileUtil.readString(new File("将数据按班级和学生成绩倒序排序.json"), StandardCharsets.UTF_8);
        List<Node> nodeList = JSON.parseArray(s, Node.class);

        executeInputDTO.setNodeList(nodeList);

        sqlModelExecutor.execute(executeInputDTO);
        System.out.println(sqlModelExecutor);

    }
}
